
using Qdb.CS.Internal;
using Qdb.CS.Internal.Messages;
using Qdb.Internal;

namespace Qdb.CS.Internal.Messages
{
	public sealed class MPrefetchIDs : MsgD, IMessageWithResponse
	{
		public Msg ReplyFromServer()
		{
			int prefetchIDCount = ReadInt();
			MsgD reply = Msg.IdList.GetWriterForLength(Transaction(), Const4.IntLength * prefetchIDCount
				);
			lock (StreamLock())
			{
				for (int i = 0; i < prefetchIDCount; i++)
				{
					reply.WriteInt(PrefetchID());
				}
			}
			return reply;
		}

		private int PrefetchID()
		{
			ServerMessageDispatcherImpl serverMessageDispatcher = (ServerMessageDispatcherImpl
				)ServerMessageDispatcher();
			return serverMessageDispatcher.PrefetchID();
		}
	}
}
